Add Claude Code GitHub Workflow#5
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds GitHub Actions workflows to enable Claude Code integration for AI-assisted development tasks. The implementation includes two workflows: one for responding to @claude mentions in comments and another for automatic code reviews on pull requests.
Changes:
- Added
.github/workflows/claude.ymlfor interactive Claude mentions in PR/issue comments - Added
.github/workflows/claude-code-review.ymlfor automatic PR code reviews
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
| .github/workflows/claude.yml | Workflow that triggers when @claude is mentioned in comments, allowing users to request AI assistance on PRs and issues |
| .github/workflows/claude-code-review.yml | Automatic code review workflow that runs on PR events using Claude's code-review plugin |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read |
There was a problem hiding this comment.
The workflow is missing write permissions that Claude Code Review may need to post its review comments. The code review tool needs to create PR comments to share its findings. However, the current permissions only grant 'read' access to contents, pull-requests, and issues.
To enable Claude to post review comments, consider adding:
pull-requests: write(for creating PR review comments)
Without write permission to pull requests, Claude will not be able to post its code review feedback.
| pull-requests: read | |
| pull-requests: write |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
The workflow lacks timeout protection, which could lead to excessive resource consumption if Claude gets stuck. GitHub Actions has a default maximum timeout of 6 hours for jobs, but it's better to set an explicit, reasonable timeout based on expected execution time.
Consider adding a timeout at the job level, for example:
timeout-minutes: 30
This ensures the workflow doesn't run indefinitely if something goes wrong.
| runs-on: ubuntu-latest | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 |
| # github.event.pull_request.user.login == 'external-contributor' || | ||
| # github.event.pull_request.user.login == 'new-developer' || | ||
| # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' | ||
|
|
There was a problem hiding this comment.
The workflow lacks timeout protection, which could lead to excessive resource consumption if the code review process gets stuck. GitHub Actions has a default maximum timeout of 6 hours for jobs, but it's better to set an explicit, reasonable timeout based on expected execution time.
Consider adding a timeout at the job level, for example:
timeout-minutes: 30
This ensures the workflow doesn't run indefinitely if something goes wrong during the code review.
| timeout-minutes: 30 |
| # - "src/**/*.tsx" | ||
| # - "src/**/*.js" | ||
| # - "src/**/*.jsx" | ||
|
|
There was a problem hiding this comment.
The workflow lacks concurrency control, which could lead to multiple Claude Code Review instances running simultaneously on the same PR. This can cause race conditions, duplicate review comments, or wasted compute resources.
Consider adding a concurrency group to ensure only one code review workflow runs per PR at a time, for example:
concurrency:
group: claude-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
This prevents multiple simultaneous code reviews on the same PR and saves resources by cancelling outdated reviews when new commits are pushed.
| concurrency: | |
| group: claude-review-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true |
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 |
There was a problem hiding this comment.
The shallow checkout with 'fetch-depth: 1' may be insufficient for Claude to properly understand the PR context. When Claude analyzes code changes, it may need access to more commit history to:
- Understand the evolution of the code
- Compare changes across multiple commits
- See the full context of modifications
Consider either:
- Using 'fetch-depth: 0' to fetch full history (better context, slower checkout)
- Using a deeper fetch like 'fetch-depth: 10' (balanced approach)
- Or explicitly setting 'fetch-depth: 2' for PRs if only the immediate change needs review
The optimal value depends on how Claude Code uses the git history. Verify with the claude-code-action documentation what depth is recommended.
| fetch-depth: 1 | |
| fetch-depth: 0 |
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
There was a problem hiding this comment.
The workflow lacks concurrency control, which could lead to multiple Claude instances running simultaneously on the same PR. This can cause race conditions, duplicate comments, or conflicting actions.
Consider adding a concurrency group to ensure only one Claude workflow runs per PR at a time, for example:
concurrency:
group: claude-${{ github.event.pull_request.number || github.event.issue.number }}
cancel-in-progress: true
This prevents multiple simultaneous executions on the same PR/issue.
| concurrency: | |
| group: claude-${{ github.event.pull_request.number || github.event.issue.number }} | |
| cancel-in-progress: true |
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] |
There was a problem hiding this comment.
The workflow runs on draft PRs, which may not be the desired behavior. The trigger includes 'opened', 'synchronize', and 'reopened' events without filtering out draft PRs, but also includes 'ready_for_review', suggesting draft PRs should be excluded.
Consider adding a condition to skip draft PRs:
if: github.event.pull_request.draft == false
This will prevent Claude from reviewing draft PRs that aren't ready for review, saving resources and avoiding premature feedback.
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) |
There was a problem hiding this comment.
There's a security concern: the PR description states "Only users with write access to the repository can trigger the workflow," but this is not enforced in the workflow configuration. The workflow triggers on 'issue_comment' and 'pull_request_review_comment' events without checking if the comment author has write access to the repository.
This means any user (including external contributors without write access) can trigger the workflow by mentioning @claude in a comment, potentially leading to:
- Unauthorized use of the Anthropic API (consuming credits)
- Spam or abuse of the Claude service
- Denial of service by repeatedly triggering the workflow
Consider adding a permission check in the job condition:
if: |
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
Note: This check would need to be adapted for each event type (issue_comment, pull_request_review_comment, etc.) since they have different data structures.
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | |
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | |
| ( | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.body, '@claude') && | |
| ( | |
| github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR' | |
| ) | |
| ) || | |
| ( | |
| github.event_name == 'pull_request_review_comment' && | |
| contains(github.event.comment.body, '@claude') && | |
| ( | |
| github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR' | |
| ) | |
| ) || | |
| ( | |
| github.event_name == 'pull_request_review' && | |
| contains(github.event.review.body, '@claude') && | |
| ( | |
| github.event.review.author_association == 'OWNER' || | |
| github.event.review.author_association == 'MEMBER' || | |
| github.event.review.author_association == 'COLLABORATOR' | |
| ) | |
| ) || | |
| ( | |
| github.event_name == 'issues' && | |
| ( | |
| contains(github.event.issue.body, '@claude') || | |
| contains(github.event.issue.title, '@claude') | |
| ) && | |
| ( | |
| github.event.issue.author_association == 'OWNER' || | |
| github.event.issue.author_association == 'MEMBER' || | |
| github.event.issue.author_association == 'COLLABORATOR' | |
| ) | |
| ) |
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@v1 |
There was a problem hiding this comment.
The workflow references the claude-code-action with a potentially unpinned version '@v1'. Using a major version tag means the workflow will automatically use the latest v1.x.x version, which could introduce breaking changes or unexpected behavior without notice.
For better security and reproducibility, consider:
- Pinning to a specific release (e.g., 'anthropics/claude-code-action@v1.0.0')
- Or using a commit SHA for maximum stability (e.g., 'anthropics/claude-code-action@abc123...')
This is especially important for workflows that can modify repository content and consume paid API credits. Verify the action's versioning strategy and choose an appropriate pinning approach.
| uses: anthropics/claude-code-action@v1 | |
| uses: anthropics/claude-code-action@v1.0.0 |
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| uses: anthropics/claude-code-action@v1 |
There was a problem hiding this comment.
The workflow references the claude-code-action with a potentially unpinned version '@v1'. Using a major version tag means the workflow will automatically use the latest v1.x.x version, which could introduce breaking changes or unexpected behavior without notice.
For better security and reproducibility, consider:
- Pinning to a specific release (e.g., 'anthropics/claude-code-action@v1.0.0')
- Or using a commit SHA for maximum stability (e.g., 'anthropics/claude-code-action@abc123...')
This is especially important for workflows that can modify repository content and consume paid API credits. Verify the action's versioning strategy and choose an appropriate pinning approach.
| uses: anthropics/claude-code-action@v1 | |
| uses: anthropics/claude-code-action@v1.0.0 |
🤖 Installing Claude Code GitHub App
This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.
What is Claude Code?
Claude Code is an AI coding agent that can help with:
How it works
Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.
Important Notes
Security
There's more information in the Claude Code action repo.
After merging this PR, let's try mentioning @claude in a comment on any PR to get started!